" csv

" Disable auto-wrapping {{{1
" can also set ft to spreadsheet, but I won't be able to use CSVArrangeColumn
autocmd BufNewFile,BufRead *.csv setlocal ft=csv

" rearrange columns {{{2
let g:rearrange_all_columns_id = 0
function! ToggleRearrangeAllColumnsFunction()
  if (g:rearrange_all_columns_id == 0)
    %CSVArrangeColumn
    let g:rearrange_all_columns_id = 1
  elseif (g:rearrange_all_columns_id == 1)
    %CSVUnArrangeColumn
    let g:rearrange_all_columns_id = 0
  endif
endfunction

nnoremap <space>ta :silent! call ToggleRearrangeAllColumnsFunction()<cr>

" disable auto line wrapping {{{1
autocmd FileType spreadsheet setlocal formatoptions-=c

" file-specific colorcolumn settings {{{1
autocmd BufEnter lab-tests.csv set colorcolumn=200
autocmd BufLeave lab-tests.csv set colorcolumn=
autocmd BufEnter vaccine.csv set colorcolumn=135
autocmd BufLeave vaccine.csv set colorcolumn=
autocmd BufEnter vision.csv set colorcolumn=128
autocmd BufLeave vision.csv set colorcolumn=
autocmd BufEnter weight.csv set colorcolumn=65
autocmd BufLeave weight.csv set colorcolumn=
autocmd BufEnter credit-score.csv set colorcolumn=41
autocmd BufLeave credit-score.csv set colorcolumn=
autocmd BufEnter net-worth.csv set colorcolumn=102
autocmd BufLeave net-worth.csv set colorcolumn=
autocmd BufEnter dental.csv set colorcolumn=104
autocmd BufLeave dental.csv set colorcolumn=
autocmd BufEnter cardiology.csv set colorcolumn=91
autocmd BufLeave cardiology.csv set colorcolumn=
autocmd BufEnter spending.csv set colorcolumn=119
autocmd BufLeave spending.csv set colorcolumn=
autocmd BufEnter online-resources.csv set colorcolumn=83
autocmd BufLeave online-resources.csv set colorcolumn=
